
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 06/14/2013 22:47:39
-- Generated from EDMX file: E:\MyWork\Now\HanGu0528\HanGu0528\HanGu\HanGu.Entity\HanGuEntity.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [HANGU.CRM];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[ActivePlan]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ActivePlan];
GO
IF OBJECT_ID(N'[dbo].[Advertisement]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Advertisement];
GO
IF OBJECT_ID(N'[dbo].[Area]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Area];
GO
IF OBJECT_ID(N'[dbo].[BemaLecturerRelation]', 'U') IS NOT NULL
    DROP TABLE [dbo].[BemaLecturerRelation];
GO
IF OBJECT_ID(N'[dbo].[ChangeChargeRecorde]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ChangeChargeRecorde];
GO
IF OBJECT_ID(N'[dbo].[ChangeGradeRecorde]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ChangeGradeRecorde];
GO
IF OBJECT_ID(N'[dbo].[ChargeRecorde]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ChargeRecorde];
GO
IF OBJECT_ID(N'[dbo].[CultureEducation]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CultureEducation];
GO
IF OBJECT_ID(N'[dbo].[Dictionary]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Dictionary];
GO
IF OBJECT_ID(N'[dbo].[EveryDayWisdom]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EveryDayWisdom];
GO
IF OBJECT_ID(N'[dbo].[FileManage]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FileManage];
GO
IF OBJECT_ID(N'[dbo].[Group]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Group];
GO
IF OBJECT_ID(N'[dbo].[LecturerInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LecturerInfo];
GO
IF OBJECT_ID(N'[dbo].[Library]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Library];
GO
IF OBJECT_ID(N'[dbo].[Manager]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Manager];
GO
IF OBJECT_ID(N'[dbo].[MemberAssigned]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberAssigned];
GO
IF OBJECT_ID(N'[dbo].[MemberAssignedHis]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberAssignedHis];
GO
IF OBJECT_ID(N'[dbo].[MemberChildren]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberChildren];
GO
IF OBJECT_ID(N'[dbo].[MemberContact]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberContact];
GO
IF OBJECT_ID(N'[dbo].[MemberContract]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberContract];
GO
IF OBJECT_ID(N'[dbo].[MemberGroup]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberGroup];
GO
IF OBJECT_ID(N'[dbo].[MemberInfo]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MemberInfo];
GO
IF OBJECT_ID(N'[dbo].[Message]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Message];
GO
IF OBJECT_ID(N'[dbo].[MessageItem]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MessageItem];
GO
IF OBJECT_ID(N'[dbo].[Module]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Module];
GO
IF OBJECT_ID(N'[dbo].[News]', 'U') IS NOT NULL
    DROP TABLE [dbo].[News];
GO
IF OBJECT_ID(N'[dbo].[PhilosopherBema]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PhilosopherBema];
GO
IF OBJECT_ID(N'[dbo].[Product]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Product];
GO
IF OBJECT_ID(N'[dbo].[Role]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Role];
GO
IF OBJECT_ID(N'[dbo].[RolePurview]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RolePurview];
GO
IF OBJECT_ID(N'[dbo].[SystemConfig]', 'U') IS NOT NULL
    DROP TABLE [dbo].[SystemConfig];
GO
IF OBJECT_ID(N'[dbo].[TravelStudy]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TravelStudy];
GO
IF OBJECT_ID(N'[dbo].[UniversallyContent]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UniversallyContent];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[VChangeChargeRecorde]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[VChangeChargeRecorde];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[VChangeGradeRecorde]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[VChangeGradeRecorde];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[VChargeRecorde]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[VChargeRecorde];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[VMemberGroup]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[VMemberGroup];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[VMemberGrouped]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[VMemberGrouped];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[VRolePurview]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[VRolePurview];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[vwMemberAssignedHis]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[vwMemberAssignedHis];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[vwMemberContact]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[vwMemberContact];
GO
IF OBJECT_ID(N'[HaiGuModelStoreContainer].[vwMessage]', 'U') IS NOT NULL
    DROP TABLE [HaiGuModelStoreContainer].[vwMessage];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'ActivePlan'
CREATE TABLE [dbo].[ActivePlan] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(100)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(100)  NULL,
    [Clicks] int  NULL,
    [GUID] varchar(36)  NOT NULL,
    [Summary] varchar(8000)  NULL,
    [Order] int  NOT NULL
);
GO

-- Creating table 'Advertisement'
CREATE TABLE [dbo].[Advertisement] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(50)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(50)  NULL,
    [ClassType] smallint  NULL,
    [PlayType] smallint  NULL,
    [FilePath] varchar(200)  NULL,
    [Title] varchar(200)  NULL,
    [Url] varchar(200)  NULL,
    [Order] int  NULL,
    [IsTitle] bit  NULL
);
GO

-- Creating table 'Area'
CREATE TABLE [dbo].[Area] (
    [AreaCode] varchar(20)  NOT NULL,
    [AreaName] nvarchar(20)  NOT NULL,
    [ParentAreaCode] varchar(20)  NOT NULL,
    [Root] bit  NOT NULL,
    [Zone] smallint  NOT NULL,
    [NavigateURL] varchar(100)  NULL
);
GO

-- Creating table 'BemaLecturerRelation'
CREATE TABLE [dbo].[BemaLecturerRelation] (
    [BemaID] int  NOT NULL,
    [Lecturer] int  NOT NULL
);
GO

-- Creating table 'ChangeChargeRecorde'
CREATE TABLE [dbo].[ChangeChargeRecorde] (
    [VIPID] int  NOT NULL,
    [ChangeValue] int  NOT NULL,
    [Changer] varchar(50)  NOT NULL,
    [ChangeTime] datetime  NULL,
    [ChangeReason] varchar(max)  NULL,
    [SourceValue] int  NOT NULL,
    [ID] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'ChangeGradeRecorde'
CREATE TABLE [dbo].[ChangeGradeRecorde] (
    [VIPID] int  NOT NULL,
    [ChangeValue] varchar(50)  NOT NULL,
    [Changer] varchar(50)  NOT NULL,
    [ChangeTime] datetime  NULL,
    [ChangeReason] varchar(max)  NULL,
    [SourceValue] varchar(50)  NULL,
    [ID] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'ChargeRecorde'
CREATE TABLE [dbo].[ChargeRecorde] (
    [VIPID] int  NOT NULL,
    [ChangeValue] int  NOT NULL,
    [Changer] varchar(50)  NOT NULL,
    [ChangeTime] datetime  NULL,
    [ChangeReason] varchar(max)  NULL,
    [User] varchar(150)  NULL,
    [SourceValue] int  NOT NULL,
    [ID] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'CultureEducation'
CREATE TABLE [dbo].[CultureEducation] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Clicks] int  NULL,
    [ClassIntroduction] varchar(5000)  NULL,
    [Suitabler] varchar(5000)  NULL,
    [ClassPlan] varchar(5000)  NULL,
    [LecturerIntroduction] varchar(5000)  NULL,
    [JoinWay] varchar(5000)  NULL,
    [Order] int  NULL,
    [GUID] varchar(36)  NOT NULL,
    [Summary] varchar(8000)  NULL,
    [ClassType] int  NULL
);
GO

-- Creating table 'Dictionary'
CREATE TABLE [dbo].[Dictionary] (
    [GroupName] varchar(200)  NOT NULL,
    [key] varchar(200)  NOT NULL,
    [Value] varchar(1000)  NULL,
    [Title] varchar(200)  NULL,
    [Remark] varchar(max)  NULL,
    [GenerateKey] varchar(400)  NULL
);
GO

-- Creating table 'EveryDayWisdom'
CREATE TABLE [dbo].[EveryDayWisdom] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(100)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(100)  NULL,
    [Author] varchar(100)  NULL,
    [GUID] varchar(36)  NOT NULL
);
GO

-- Creating table 'FileManage'
CREATE TABLE [dbo].[FileManage] (
    [GUID] varchar(36)  NOT NULL,
    [FileType] varchar(50)  NULL,
    [FilePath] varchar(max)  NULL,
    [Photo] varbinary(max)  NULL,
    [IsUse] bit  NOT NULL,
    [GroupName] varchar(150)  NULL,
    [Uploader] varchar(150)  NULL,
    [UploadTime] datetime  NOT NULL,
    [ID] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'Group'
CREATE TABLE [dbo].[Group] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [GroupName] varchar(500)  NULL,
    [Remark] varchar(8000)  NULL,
    [MemberID] varchar(8000)  NULL
);
GO

-- Creating table 'LecturerInfo'
CREATE TABLE [dbo].[LecturerInfo] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] varchar(100)  NULL,
    [Reamark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(100)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(100)  NULL,
    [Grade] int  NULL,
    [Contribution] varchar(max)  NULL,
    [GUID] varchar(36)  NOT NULL,
    [TitlePic] varchar(200)  NULL,
    [Summary] varchar(8000)  NULL,
    [Order] int  NULL
);
GO

-- Creating table 'Library'
CREATE TABLE [dbo].[Library] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Clicks] int  NULL,
    [Charge] int  NULL,
    [FilePath] varchar(200)  NULL,
    [GUID] varchar(36)  NOT NULL,
    [Summary] varchar(8000)  NULL
);
GO

-- Creating table 'Manager'
CREATE TABLE [dbo].[Manager] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [User] varchar(200)  NULL,
    [Pwd] varchar(200)  NULL,
    [RealName] varchar(200)  NULL,
    [RoleID] int  NULL,
    [Creator] varchar(200)  NULL,
    [CreateTime] datetime  NULL,
    [Position] varchar(200)  NULL,
    [Parent] int  NULL,
    [IsDirectly] bit  NULL,
    [Status] smallint  NULL,
    [Sex] smallint  NULL,
    [Age] int  NULL,
    [InWorkDate] datetime  NULL,
    [OutWorkDate] datetime  NULL
);
GO

-- Creating table 'MemberAssigned'
CREATE TABLE [dbo].[MemberAssigned] (
    [ManagerID] int  NOT NULL,
    [MemberID] int  NOT NULL
);
GO

-- Creating table 'MemberAssignedHis'
CREATE TABLE [dbo].[MemberAssignedHis] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [MemberID] int  NOT NULL,
    [ManagerID] int  NOT NULL,
    [CreateDate] datetime  NULL
);
GO

-- Creating table 'MemberChildren'
CREATE TABLE [dbo].[MemberChildren] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ParentID] int  NOT NULL,
    [Sex] varchar(50)  NULL,
    [RealName] varchar(50)  NULL,
    [Birthday] datetime  NULL
);
GO

-- Creating table 'MemberContract'
CREATE TABLE [dbo].[MemberContract] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [StarDate] datetime  NULL,
    [Remark] varchar(max)  NULL,
    [Amount] decimal(18,2)  NOT NULL,
    [FilePath] varchar(150)  NULL,
    [Creator] varchar(50)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [ParentID] int  NULL
);
GO

-- Creating table 'MemberGroup'
CREATE TABLE [dbo].[MemberGroup] (
    [GroupID] int  NOT NULL,
    [MemberID] int  NOT NULL
);
GO

-- Creating table 'MemberInfo'
CREATE TABLE [dbo].[MemberInfo] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [RealName] varchar(100)  NULL,
    [Sex] varchar(100)  NULL,
    [IsMarry] varchar(100)  NULL,
    [Tel] varchar(100)  NULL,
    [Email] varchar(100)  NULL,
    [CredentialNum] varchar(100)  NULL,
    [Provice] varchar(100)  NULL,
    [City] varchar(100)  NULL,
    [Address] varchar(200)  NULL,
    [Zip] varchar(100)  NULL,
    [NativePlace] varchar(100)  NULL,
    [Job] varchar(100)  NULL,
    [WorkAddress] varchar(200)  NULL,
    [Trade] varchar(100)  NULL,
    [Position] varchar(100)  NULL,
    [JobOther] varchar(100)  NULL,
    [TradeOther] varchar(100)  NULL,
    [Interest] varchar(1000)  NULL,
    [Introduction] varchar(max)  NULL,
    [Grade] varchar(100)  NULL,
    [Charge] decimal(18,2)  NULL,
    [UserName] varchar(100)  NOT NULL,
    [Pwd] varchar(100)  NOT NULL,
    [RelationMem] varchar(100)  NULL,
    [PicPath] varchar(100)  NULL,
    [NoSMS] bit  NOT NULL,
    [NoTel] bit  NOT NULL,
    [NoEmail] bit  NOT NULL,
    [GUID] varchar(36)  NOT NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Degree] varchar(100)  NULL,
    [GroupID] varchar(1000)  NULL,
    [Birthday] datetime  NULL,
    [IsChildren] bit  NOT NULL,
    [Telephone] varchar(50)  NULL,
    [Oganization] varchar(150)  NULL,
    [IsDirectly] bit  NOT NULL,
    [IsBacklist] bit  NOT NULL,
    [ImportantLevel] varchar(150)  NULL,
    [ContractTotal] decimal(18,2)  NULL,
    [ContractNum] int  NULL,
    [QLink] varchar(200)  NULL,
    [IsNew] bit  NOT NULL
);
GO

-- Creating table 'Message'
CREATE TABLE [dbo].[Message] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Type] int  NOT NULL,
    [Title] varchar(250)  NULL,
    [MemberID] int  NOT NULL,
    [Receiver] varchar(5000)  NULL,
    [Remark] varchar(max)  NULL,
    [Creator] varchar(50)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [GUID] varchar(36)  NOT NULL,
    [State] int  NOT NULL,
    [CreatorID] int  NULL,
    [IsCust] bit  NOT NULL,
    [Manager] varchar(5000)  NULL
);
GO

-- Creating table 'MessageItem'
CREATE TABLE [dbo].[MessageItem] (
    [MsgID] int  NOT NULL,
    [ID] int IDENTITY(1,1) NOT NULL,
    [Receiver] varchar(50)  NOT NULL,
    [MemberID] int  NOT NULL
);
GO

-- Creating table 'Module'
CREATE TABLE [dbo].[Module] (
    [ID] varchar(200)  NOT NULL,
    [ModuleName] varchar(200)  NULL,
    [Title] varchar(200)  NULL,
    [Url] varchar(200)  NULL,
    [Order] int  NULL,
    [Parent] varchar(200)  NULL,
    [Remark] varchar(max)  NULL,
    [GUID] varchar(36)  NULL,
    [AdXml] varchar(200)  NULL,
    [Types] int  NULL,
    [ParmFormat] varchar(200)  NULL,
    [OnCilck] varchar(200)  NULL,
    [CssClass] varchar(200)  NULL,
    [Target] varchar(200)  NULL,
    [External] varchar(200)  NULL,
    [Fresh] varchar(200)  NULL,
    [Warn] varchar(200)  NULL,
    [Reverse] bit  NULL
);
GO

-- Creating table 'News'
CREATE TABLE [dbo].[News] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Clicks] int  NULL,
    [GUID] varchar(36)  NOT NULL,
    [Summary] varchar(8000)  NULL,
    [Order] int  NULL
);
GO

-- Creating table 'PhilosopherBema'
CREATE TABLE [dbo].[PhilosopherBema] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Lecturer] varchar(200)  NULL,
    [PlayTime] datetime  NULL,
    [Clicks] int  NULL,
    [PlayAddress] varchar(200)  NULL,
    [IsTop] bit  NULL,
    [LimiteGrade] varchar(200)  NULL,
    [GUID] varchar(36)  NOT NULL,
    [PlayURL] varchar(200)  NULL,
    [Summary] varchar(8000)  NULL,
    [ClassType] int  NOT NULL,
    [RedirectUrl] varchar(200)  NULL,
    [LecturerID] varchar(8000)  NULL,
    [Catalog] varchar(8000)  NULL,
    [Order] int  NOT NULL
);
GO

-- Creating table 'Product'
CREATE TABLE [dbo].[Product] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Clicks] int  NULL,
    [Charge] int  NULL,
    [GUID] varchar(36)  NOT NULL,
    [Summary] varchar(8000)  NULL,
    [Price] float  NULL,
    [Order] int  NULL
);
GO

-- Creating table 'Role'
CREATE TABLE [dbo].[Role] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] varchar(200)  NULL,
    [Remark] varchar(max)  NULL,
    [Creator] varchar(200)  NULL,
    [CreateTime] datetime  NULL
);
GO

-- Creating table 'RolePurview'
CREATE TABLE [dbo].[RolePurview] (
    [RoleID] int  NOT NULL,
    [ModulelID] varchar(200)  NOT NULL
);
GO

-- Creating table 'SystemConfig'
CREATE TABLE [dbo].[SystemConfig] (
    [Key] varchar(100)  NOT NULL,
    [Value] varchar(1500)  NOT NULL,
    [Title] varchar(500)  NULL
);
GO

-- Creating table 'TravelStudy'
CREATE TABLE [dbo].[TravelStudy] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Clicks] int  NULL,
    [Address] varchar(200)  NULL,
    [IsTop] bit  NULL,
    [GUID] varchar(36)  NOT NULL,
    [TravelTime] datetime  NULL,
    [TraveEndlTime] datetime  NULL,
    [Summary] varchar(8000)  NULL,
    [ClassType] int  NOT NULL,
    [RedirectUrl] varchar(200)  NULL,
    [Order] int  NOT NULL,
    [PlayURL] varchar(500)  NULL
);
GO

-- Creating table 'UniversallyContent'
CREATE TABLE [dbo].[UniversallyContent] (
    [ID] int  NOT NULL,
    [Title] varchar(200)  NULL,
    [TitlePic] varchar(200)  NULL,
    [IsIndex] bit  NULL,
    [Remark] varchar(max)  NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Clicks] int  NULL,
    [CType] int  NULL,
    [GUID] varchar(36)  NOT NULL,
    [Summary] varchar(8000)  NULL,
    [Order] int  NULL
);
GO

-- Creating table 'VChangeChargeRecorde'
CREATE TABLE [dbo].[VChangeChargeRecorde] (
    [VIPID] int  NOT NULL,
    [ChangeValue] int  NOT NULL,
    [Changer] varchar(50)  NOT NULL,
    [ChangeTime] datetime  NULL,
    [ChangeReason] varchar(max)  NULL,
    [SourceValue] int  NOT NULL,
    [ID] int  NOT NULL,
    [MemberName] varchar(202)  NULL
);
GO

-- Creating table 'VChangeGradeRecorde'
CREATE TABLE [dbo].[VChangeGradeRecorde] (
    [VIPID] int  NOT NULL,
    [ChangeValue] varchar(50)  NOT NULL,
    [Changer] varchar(50)  NOT NULL,
    [ChangeTime] datetime  NULL,
    [ChangeReason] varchar(max)  NULL,
    [SourceValue] varchar(50)  NULL,
    [ID] int  NOT NULL,
    [MemberName] varchar(202)  NULL,
    [SourceDegree] varchar(1000)  NULL,
    [ChangeDegree] varchar(1000)  NULL
);
GO

-- Creating table 'VChargeRecorde'
CREATE TABLE [dbo].[VChargeRecorde] (
    [VIPID] int  NOT NULL,
    [ChangeValue] int  NOT NULL,
    [Changer] varchar(50)  NOT NULL,
    [ChangeTime] datetime  NULL,
    [ChangeReason] varchar(max)  NULL,
    [User] varchar(150)  NULL,
    [SourceValue] int  NOT NULL,
    [ID] int  NOT NULL,
    [MemberName] varchar(202)  NULL
);
GO

-- Creating table 'VMemberGroup'
CREATE TABLE [dbo].[VMemberGroup] (
    [ID] int  NOT NULL,
    [RealName] varchar(100)  NULL,
    [Sex] varchar(100)  NULL,
    [IsMarry] varchar(100)  NULL,
    [Tel] varchar(100)  NULL,
    [Email] varchar(100)  NOT NULL,
    [CredentialNum] varchar(100)  NULL,
    [Provice] varchar(100)  NULL,
    [City] varchar(100)  NULL,
    [Address] varchar(200)  NULL,
    [Zip] varchar(100)  NULL,
    [NativePlace] varchar(100)  NULL,
    [Job] varchar(100)  NULL,
    [WorkAddress] varchar(200)  NULL,
    [Trade] varchar(100)  NULL,
    [Position] varchar(100)  NULL,
    [JobOther] varchar(100)  NULL,
    [TradeOther] varchar(100)  NULL,
    [Interest] varchar(1000)  NULL,
    [Introduction] varchar(max)  NULL,
    [Grade] varchar(100)  NULL,
    [Charge] decimal(18,2)  NULL,
    [UserName] varchar(100)  NOT NULL,
    [Pwd] varchar(100)  NOT NULL,
    [RelationMem] varchar(100)  NULL,
    [PicPath] varchar(100)  NULL,
    [NoSMS] bit  NOT NULL,
    [NoTel] bit  NOT NULL,
    [NoEmail] bit  NOT NULL,
    [GUID] varchar(36)  NOT NULL,
    [CreateTime] datetime  NULL,
    [Creator] varchar(200)  NULL,
    [UpdateTime] datetime  NULL,
    [Updater] varchar(200)  NULL,
    [Degree] varchar(100)  NULL,
    [GroupID] varchar(1000)  NULL,
    [Birthday] datetime  NULL,
    [IsChildren] bit  NOT NULL,
    [Telephone] varchar(50)  NULL,
    [Oganization] varchar(150)  NULL,
    [AssignedIn] int  NULL,
    [IsDirectly] bit  NOT NULL,
    [IsBacklist] bit  NOT NULL,
    [ImportantLevel] varchar(150)  NULL,
    [ContractTotal] decimal(18,2)  NULL,
    [ContractNum] int  NULL,
    [QLink] varchar(200)  NULL,
    [IsNew] bit  NOT NULL,
    [GroupsId] int  NULL
);
GO

-- Creating table 'VMemberGrouped'
CREATE TABLE [dbo].[VMemberGrouped] (
    [GroupID] int  NOT NULL,
    [MemberID] int  NOT NULL,
    [RealName] varchar(100)  NULL,
    [UserName] varchar(100)  NOT NULL,
    [GroupName] varchar(500)  NULL
);
GO

-- Creating table 'VRolePurview'
CREATE TABLE [dbo].[VRolePurview] (
    [Name] varchar(200)  NULL,
    [RoleRemark] varchar(max)  NULL,
    [Creator] varchar(200)  NULL,
    [CreateTime] datetime  NULL,
    [RoleID] int  NOT NULL,
    [ModulelID] varchar(200)  NOT NULL,
    [ID] varchar(200)  NOT NULL,
    [Title] varchar(200)  NULL,
    [Url] varchar(200)  NULL,
    [Order] int  NULL,
    [Remark] varchar(max)  NULL,
    [GUID] varchar(36)  NULL,
    [AdXml] varchar(200)  NULL,
    [Types] int  NULL,
    [ParmFormat] varchar(200)  NULL,
    [OnCilck] varchar(200)  NULL,
    [Parent] varchar(200)  NULL,
    [CssClass] varchar(200)  NULL,
    [Target] varchar(200)  NULL,
    [Fresh] varchar(200)  NULL,
    [External] varchar(200)  NULL,
    [ModuleName] varchar(200)  NULL,
    [Warn] varchar(200)  NULL,
    [Reverse] bit  NULL
);
GO

-- Creating table 'vwMemberAssignedHis'
CREATE TABLE [dbo].[vwMemberAssignedHis] (
    [MemberName] varchar(100)  NULL,
    [MemberID] int  NOT NULL,
    [ManagerID] int  NOT NULL,
    [CreateDate] datetime  NULL,
    [ManagerName] varchar(200)  NULL,
    [User] varchar(200)  NULL,
    [ID] int  NOT NULL
);
GO

-- Creating table 'vwMessage'
CREATE TABLE [dbo].[vwMessage] (
    [ID] int  NOT NULL,
    [Type] int  NOT NULL,
    [Title] varchar(250)  NULL,
    [Remark] varchar(max)  NULL,
    [Creator] varchar(50)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [GUID] varchar(36)  NOT NULL,
    [State] int  NOT NULL,
    [Tel] varchar(100)  NULL,
    [Telephone] varchar(50)  NULL,
    [Receiver] varchar(5000)  NULL,
    [MemberID] int  NOT NULL,
    [RealName] varchar(100)  NULL,
    [Email] varchar(100)  NULL
);
GO

-- Creating table 'MemberContact'
CREATE TABLE [dbo].[MemberContact] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Type] varchar(50)  NOT NULL,
    [Title] varchar(250)  NULL,
    [MemberID] int  NOT NULL,
    [Remark] varchar(max)  NULL,
    [Creator] varchar(50)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [CreatorID] int  NOT NULL,
    [Manager] varchar(5000)  NULL
);
GO

-- Creating table 'vwMemberContact'
CREATE TABLE [dbo].[vwMemberContact] (
    [ID] int  NOT NULL,
    [Type] varchar(50)  NOT NULL,
    [Title] varchar(250)  NULL,
    [MemberID] int  NOT NULL,
    [Remark] varchar(max)  NULL,
    [Creator] varchar(50)  NOT NULL,
    [CreateTime] datetime  NOT NULL,
    [CreatorID] int  NOT NULL,
    [Manager] varchar(5000)  NULL,
    [RealName] varchar(100)  NULL,
    [TypeName] varchar(1000)  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'ActivePlan'
ALTER TABLE [dbo].[ActivePlan]
ADD CONSTRAINT [PK_ActivePlan]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Advertisement'
ALTER TABLE [dbo].[Advertisement]
ADD CONSTRAINT [PK_Advertisement]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [AreaCode] in table 'Area'
ALTER TABLE [dbo].[Area]
ADD CONSTRAINT [PK_Area]
    PRIMARY KEY CLUSTERED ([AreaCode] ASC);
GO

-- Creating primary key on [BemaID], [Lecturer] in table 'BemaLecturerRelation'
ALTER TABLE [dbo].[BemaLecturerRelation]
ADD CONSTRAINT [PK_BemaLecturerRelation]
    PRIMARY KEY CLUSTERED ([BemaID], [Lecturer] ASC);
GO

-- Creating primary key on [ID] in table 'ChangeChargeRecorde'
ALTER TABLE [dbo].[ChangeChargeRecorde]
ADD CONSTRAINT [PK_ChangeChargeRecorde]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ChangeGradeRecorde'
ALTER TABLE [dbo].[ChangeGradeRecorde]
ADD CONSTRAINT [PK_ChangeGradeRecorde]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'ChargeRecorde'
ALTER TABLE [dbo].[ChargeRecorde]
ADD CONSTRAINT [PK_ChargeRecorde]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'CultureEducation'
ALTER TABLE [dbo].[CultureEducation]
ADD CONSTRAINT [PK_CultureEducation]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [GroupName], [key] in table 'Dictionary'
ALTER TABLE [dbo].[Dictionary]
ADD CONSTRAINT [PK_Dictionary]
    PRIMARY KEY CLUSTERED ([GroupName], [key] ASC);
GO

-- Creating primary key on [ID] in table 'EveryDayWisdom'
ALTER TABLE [dbo].[EveryDayWisdom]
ADD CONSTRAINT [PK_EveryDayWisdom]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'FileManage'
ALTER TABLE [dbo].[FileManage]
ADD CONSTRAINT [PK_FileManage]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Group'
ALTER TABLE [dbo].[Group]
ADD CONSTRAINT [PK_Group]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'LecturerInfo'
ALTER TABLE [dbo].[LecturerInfo]
ADD CONSTRAINT [PK_LecturerInfo]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Library'
ALTER TABLE [dbo].[Library]
ADD CONSTRAINT [PK_Library]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Manager'
ALTER TABLE [dbo].[Manager]
ADD CONSTRAINT [PK_Manager]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ManagerID], [MemberID] in table 'MemberAssigned'
ALTER TABLE [dbo].[MemberAssigned]
ADD CONSTRAINT [PK_MemberAssigned]
    PRIMARY KEY CLUSTERED ([ManagerID], [MemberID] ASC);
GO

-- Creating primary key on [ID] in table 'MemberAssignedHis'
ALTER TABLE [dbo].[MemberAssignedHis]
ADD CONSTRAINT [PK_MemberAssignedHis]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'MemberChildren'
ALTER TABLE [dbo].[MemberChildren]
ADD CONSTRAINT [PK_MemberChildren]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'MemberContract'
ALTER TABLE [dbo].[MemberContract]
ADD CONSTRAINT [PK_MemberContract]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [GroupID], [MemberID] in table 'MemberGroup'
ALTER TABLE [dbo].[MemberGroup]
ADD CONSTRAINT [PK_MemberGroup]
    PRIMARY KEY CLUSTERED ([GroupID], [MemberID] ASC);
GO

-- Creating primary key on [ID] in table 'MemberInfo'
ALTER TABLE [dbo].[MemberInfo]
ADD CONSTRAINT [PK_MemberInfo]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Message'
ALTER TABLE [dbo].[Message]
ADD CONSTRAINT [PK_Message]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'MessageItem'
ALTER TABLE [dbo].[MessageItem]
ADD CONSTRAINT [PK_MessageItem]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Module'
ALTER TABLE [dbo].[Module]
ADD CONSTRAINT [PK_Module]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'News'
ALTER TABLE [dbo].[News]
ADD CONSTRAINT [PK_News]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'PhilosopherBema'
ALTER TABLE [dbo].[PhilosopherBema]
ADD CONSTRAINT [PK_PhilosopherBema]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Product'
ALTER TABLE [dbo].[Product]
ADD CONSTRAINT [PK_Product]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Role'
ALTER TABLE [dbo].[Role]
ADD CONSTRAINT [PK_Role]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [RoleID], [ModulelID] in table 'RolePurview'
ALTER TABLE [dbo].[RolePurview]
ADD CONSTRAINT [PK_RolePurview]
    PRIMARY KEY CLUSTERED ([RoleID], [ModulelID] ASC);
GO

-- Creating primary key on [Key] in table 'SystemConfig'
ALTER TABLE [dbo].[SystemConfig]
ADD CONSTRAINT [PK_SystemConfig]
    PRIMARY KEY CLUSTERED ([Key] ASC);
GO

-- Creating primary key on [ID] in table 'TravelStudy'
ALTER TABLE [dbo].[TravelStudy]
ADD CONSTRAINT [PK_TravelStudy]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'UniversallyContent'
ALTER TABLE [dbo].[UniversallyContent]
ADD CONSTRAINT [PK_UniversallyContent]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [VIPID], [ChangeValue], [Changer], [SourceValue], [ID] in table 'VChangeChargeRecorde'
ALTER TABLE [dbo].[VChangeChargeRecorde]
ADD CONSTRAINT [PK_VChangeChargeRecorde]
    PRIMARY KEY CLUSTERED ([VIPID], [ChangeValue], [Changer], [SourceValue], [ID] ASC);
GO

-- Creating primary key on [VIPID], [ChangeValue], [Changer], [ID] in table 'VChangeGradeRecorde'
ALTER TABLE [dbo].[VChangeGradeRecorde]
ADD CONSTRAINT [PK_VChangeGradeRecorde]
    PRIMARY KEY CLUSTERED ([VIPID], [ChangeValue], [Changer], [ID] ASC);
GO

-- Creating primary key on [VIPID], [ChangeValue], [Changer], [SourceValue], [ID] in table 'VChargeRecorde'
ALTER TABLE [dbo].[VChargeRecorde]
ADD CONSTRAINT [PK_VChargeRecorde]
    PRIMARY KEY CLUSTERED ([VIPID], [ChangeValue], [Changer], [SourceValue], [ID] ASC);
GO

-- Creating primary key on [ID], [Email], [UserName], [Pwd], [NoSMS], [NoTel], [NoEmail], [GUID], [IsChildren], [IsDirectly], [IsBacklist], [IsNew] in table 'VMemberGroup'
ALTER TABLE [dbo].[VMemberGroup]
ADD CONSTRAINT [PK_VMemberGroup]
    PRIMARY KEY CLUSTERED ([ID], [Email], [UserName], [Pwd], [NoSMS], [NoTel], [NoEmail], [GUID], [IsChildren], [IsDirectly], [IsBacklist], [IsNew] ASC);
GO

-- Creating primary key on [GroupID], [MemberID], [UserName] in table 'VMemberGrouped'
ALTER TABLE [dbo].[VMemberGrouped]
ADD CONSTRAINT [PK_VMemberGrouped]
    PRIMARY KEY CLUSTERED ([GroupID], [MemberID], [UserName] ASC);
GO

-- Creating primary key on [RoleID], [ModulelID], [ID] in table 'VRolePurview'
ALTER TABLE [dbo].[VRolePurview]
ADD CONSTRAINT [PK_VRolePurview]
    PRIMARY KEY CLUSTERED ([RoleID], [ModulelID], [ID] ASC);
GO

-- Creating primary key on [MemberID], [ManagerID], [ID] in table 'vwMemberAssignedHis'
ALTER TABLE [dbo].[vwMemberAssignedHis]
ADD CONSTRAINT [PK_vwMemberAssignedHis]
    PRIMARY KEY CLUSTERED ([MemberID], [ManagerID], [ID] ASC);
GO

-- Creating primary key on [ID], [Type], [Creator], [CreateTime], [GUID], [State], [MemberID] in table 'vwMessage'
ALTER TABLE [dbo].[vwMessage]
ADD CONSTRAINT [PK_vwMessage]
    PRIMARY KEY CLUSTERED ([ID], [Type], [Creator], [CreateTime], [GUID], [State], [MemberID] ASC);
GO

-- Creating primary key on [ID] in table 'MemberContact'
ALTER TABLE [dbo].[MemberContact]
ADD CONSTRAINT [PK_MemberContact]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID], [Type], [MemberID], [Creator], [CreateTime], [CreatorID] in table 'vwMemberContact'
ALTER TABLE [dbo].[vwMemberContact]
ADD CONSTRAINT [PK_vwMemberContact]
    PRIMARY KEY CLUSTERED ([ID], [Type], [MemberID], [Creator], [CreateTime], [CreatorID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------